package com.qiyue.admin.auth.utils.jwt.exceotion;

import com.qiyue.common.constant.CommonConstants;
import com.qiyue.common.exception.BaseException;
import com.qiyue.common.exception.BaseExceptionModel;

import java.util.HashMap;
import java.util.Map;

/**
 * Created with Intellij IDEA.
 * User : Yebinghuan
 * Created on 2018/2/10.
 * Description :
 *   用户token异常
 */
public class UserTokenException extends BaseException {






    public UserTokenException(BaseExceptionModel model) {
        super(model.getMessage(), model.getCode());
    }

    /**
     * 构建一个用户异常反馈
     * @param type 0--过期  1-- 错误 2--token不存在
     * @return
     */
    public static BaseExceptionModel getExceptionModel(int type){
        String message = null;
        int code = CommonConstants.ExceptionConstants.EX_USER_ERROR_CODE;
        switch (type)
        {
            case 0:  //用户令牌已经过期
                message = "User token expired!";
                code = CommonConstants.ExceptionConstants.EX_USER_INVALID_CODE ;
                break;
            case 1:  // 令牌错误
                message = "User token signature error!";
                code = CommonConstants.ExceptionConstants.EX_USER_ERROR_CODE ;
            case 2:
                message = "User token is null or empty!";
                code = CommonConstants.ExceptionConstants.EX_USER_ISNULL_CODE ;
        }
        return new BaseExceptionModel(message, code);
    }


}
